package com.sxd.bill.common.item;

import java.util.ArrayList;
import java.util.List;
import lombok.Data;

@Data
public class TextLabelItem implements Cloneable {
    private String text;
    private List<LabelItem> labelItems;

    public TextLabelItem(String text, List<LabelItem> labelItems) {
        this.text = text;
        this.labelItems = labelItems;
    }

    public TextLabelItem() {

    }

    @Override
    public TextLabelItem clone() {
        try {
            TextLabelItem cloned = (TextLabelItem) super.clone();
            // 克隆labelItems列表中的每个LabelItem对象
            cloned.labelItems = new ArrayList<>();
            for (LabelItem item : this.labelItems) {
                cloned.labelItems.add(item.clone());
            }
            return cloned;
        } catch (CloneNotSupportedException e) {
            throw new RuntimeException(e);
        }
    }
}
